package com.example.springboot3demo.service.lock;

import org.redisson.api.RLock;

import java.util.concurrent.TimeUnit;

public interface IDistributedLock {

    // 获取锁，默认30秒失效，失败一直等待直到获取锁
    RLock lock(String key);

    // 获取锁,失败一直等待直到获取锁
    RLock lock(String key, long lockTime, TimeUnit unit, boolean fair);

    // 尝试获取锁，30秒获取不到超时异常，锁默认30秒失效
    RLock tryLock(String key, long tryTime) throws Exception;

    // 尝试获取锁，获取不到超时异常
    RLock tryLock(String key, long tryTime, long lockTime, TimeUnit unit, boolean fair) throws Exception;

    // 解锁
    void unLock(RLock lock);


}
